package net.xepherx.ytdl;


import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class Utils {
	
	public static String getUrlContent(URL url) throws IOException{
		
		HttpURLConnection connection = (HttpURLConnection)url.openConnection();
		connection.setRequestMethod("GET");
		connection.connect();

		InputStream stream = connection.getInputStream();
		
		java.util.Scanner scanner = new java.util.Scanner(stream);
		java.util.Scanner scannerDelim = scanner.useDelimiter("\\A");
		
	    String out = scannerDelim.hasNext() ? scannerDelim.next() : "";

	    scannerDelim.close();
		scanner.close();
	    stream.close();
		
		return out;
	}
}
